<?php
class indexApp extends core 
{
	public function indexAction()
	{
		$template	= $this->template();
		$user       = base::init('user')->getInfo();
		$template->assign('user',$user);
		$template->display('index.php');
	}

	public function manAction()
	{
		$template = $this->template();

		#缓存3分钟
		#$template->caching = true;
		#$template->cache_lifetime = 60*3;

		if(!$template->is_cached('index_man.php'))
		{
			#用户数
			$users		= count(base::init('user')->fetchAll());
            $user       = base::init('user')->getInfo();
            #$group      = base::init('group')->fetchAll(array('gid'=>$user['gid']));
            #$groups     = sort_combine($group,'wid',false);
            $websites   = base::init('website')->fetchAll();
            $websites   = sort_combine($websites,'wid',true);
            #文章信息数
			$articles	= base::init('article')->getCount();//article::getNumByWhere("my_article.aid=my_article_data_1.aid");
	
			#系统信息
			$info = array();
			$info['serverinfo']	= PHP_OS.' / PHP v'.PHP_VERSION;
			$info['serverinfo']	.= @ini_get('safe_mode') ? ' Safe Mode' : NULL;
	
			$info['dbversion']	= base::dbVersion();
			$info['fileupload']	= @ini_get('file_uploads') ? ini_get('upload_max_filesize') : '<font color="red">'.$lang['no'].'</font>';
			$info['dbsize']		= 0;
	
			$query = $tables = base::dbTableStatus();
			foreach($tables as $table) {
				$info['dbsize'] += $table['Data_length'] + $table['Index_length'];
			}
	
			$info['dbsize'] = $info['dbsize'] ? _sizecount($info['dbsize']) : $lang['unknown'];
			$info['magic_quote_gpc'] = get_magic_quotes_gpc() ? 'On' : 'Off';
			$info['safe_mode']		= ini_get('safe_mode') ? 'On' : 'Off';
			$info['ip']		= get_real_ip();
			$info['date']	= date("Y-m-d H:i");
			$info['domain']	= $_SERVER['SERVER_NAME'];
	
			$template->assign('info',$info);
			$template->assign('users',$users);
			$template->assign('websites',$websites);
			$template->assign('user',$user);
			#$template->assign('group',$group);
			$template->assign('articles',$articles);
		}
		$template->display('index_man.php');
	}
	
	public function testAction(){
		$columns	= base::init('column')->fetchAll();
		
		foreach ($columns as $column)
		{
			if ($column['bclassid'])
			{
				$path	= array_pop(explode('/',$column['classpath']));
				$bc		= array_pop(explode('/',$columns[$column['bclassid']]['classpath']));
				base::init('column')->update(
					array('domain'=>'http://'.$bc.'.365inf.com/'.$path),
					array('classid'=>$column['classid'])
				);
			}
			else 
			{
				$path	= array_pop(explode('/',$column['classpath']));
				base::init('column')->update(
					array('domain'=>'http://'.$path.'.365inf.com'),
					array('classid'=>$column['classid'])
				);
			}
		}
	}
}
